const request = require('../../request/index')

async function getPic(keyword) {
    let result = await request.get(`https://cn.bing.com/images/search?q=${encodeURI(keyword)}&form=HDRSC2&first=1&cw=1177&ch=714`)
    let pics = result.toString().match(/(?<=(img[^>]*src="))[^"]*/g)
    let _ = []
    for (let i = 0; i < pics.length; i++) {
        if (pics[i].includes('http')) {
            _.push(pics[i])
        }
    }
    return _
}

module.exports=exports = getPic